{erl_opts, [debug_info,
            {i, ["include"]}]}.

%% For behaviour info
{erl_first_files, [
    "src/gen_mod.erl",
    "src/mod_event_pusher_sns.erl"
]}.

{xref_checks, [undefined_function_calls,
               undefined_functions,
               locals_not_used,
               exports_not_used,
               deprecated_function_calls,
               deprecated_functions]}.

{xref_ignores, [
    eldap_filter_yecc, 'XmppAddr', mongoose_xmpp_errors,
    %% *_backend
    mod_bosh_backend,
    mod_global_distrib_mapping_backend,
    mod_pubsub_db_backend,
    mod_shared_roster,
    ejabberd_local,
    mongoose_c2s,
    mongoose_c2s_acc,
    %% Deprecated functions
    {crypto, rand_uniform, 2},
    {ranch, start_listener, 6},
    {ranch, accept_ack, 1},
    {mongoose_lib, deprecated_logging, 1},
    {sys, get_debug, 3},
    {httpd_util, integer_to_hexlist, 1}
]}.

{require_min_otp_vsn, "26"}.

%% We agreed to use https:// for deps because of possible firewall issues.
%%
%% If you still prefer git protocol, update your "~/.gitconfig" by running:
%% git config --global url."git://github".insteadOf https://github
{deps,
 [
  %%% Stateless parsers
  {exml, "4.1.2", {pkg, hexml}},
  {jiffy, "1.1.2"},
  {jid, "2.2.2", {pkg, mongoose_jid}},
  {tomerl, "0.5.0"},
  {bbmustache, "1.12.2"},
  {erl_csv, "0.3.3"},

  %%% Observability
  {telemetry, "1.3.0"},
  {exometer_core, {git, "https://github.com/esl/exometer_core.git", {branch, "master"}}},
  {exometer_report_graphite, {git, "https://github.com/esl/exometer_report_graphite.git", {branch, "master"}}},
  {exometer_report_statsd, {git, "https://github.com/esl/exometer_report_statsd.git", {branch, "master"}}},
  {syslogger, "0.3.0"},
  {flatlog, "0.1.2"},
  {prometheus, "5.0.0"},
  {prometheus_cowboy, "0.1.9"},

  %%% Stateless libraries
  {opuntia, "1.1.2"},
  {fast_scram, "0.7.0"},
  {idna, "6.1.1"},
  {uuid, "2.0.7", {pkg, uuid_erl}},
  {gen_fsm_compat, "0.3.0"},

  %%% Stateful apps
  {cache_tab, "1.0.31"},
  {segmented_cache, "0.4.0"},
  {worker_pool, "6.4.0"},
  {cets, "0.3.0"},

  %%% HTTP tools
  {graphql, "0.17.1", {pkg, graphql_erl}},
  {ranch, "2.2.0"},
  {cowboy, "2.13.0"},
  {hackney, "1.23.0"}, %% Erlcloud needs this
  {gun, "2.1.0"},
  {fusco, "0.1.1"},
  {lasse, "1.2.0"},
  {trails, "2.3.1"},
  {cowboy_swagger, "2.7.0"},

  %%% Outgoing pools
  {cqerl, {git, "https://github.com/esl/cqerl.git", {branch, "master"}}},
  {mysql, "1.9.0"},
  {epgsql, "4.7.1"},
  {eodbc, "0.2.0"},
  {tirerl, "1.2.0"},
  {amqp_client, "4.2.1"},
  {eredis, "1.7.1"},
  {erlcloud, "3.8.3"},

  %%% Internal monitoring and debugging tools
  {recon, "2.5.6"},
  {observer_cli, "1.8.2"},
  {erlang_doctor, "0.2.8"},

  %%% Other
  {pa, {git, "https://github.com/erszcz/pa.git", {branch, "master"}}},
  {jwerl, "1.2.0"},
  {cpool, "0.1.0"}, %% Do not upgrade cpool to version 0.1.1, it has bugs
  {nksip, {git, "https://github.com/esl/nksip.git", {branch, "mongooseim"}}},

  %% nkservice pulls lua. We cannot override it, because it is listed in nkservice.app file
  {luerl, "1.3.0"}
 ]}.

{relx, [{release, {mongooseim, {file, "VERSION"}}, []}, %%Apps list is dynamicaly set by rebar.config.script

        %% Disable some warnings in systools:make_script/2 which are extremely slow (saves 30 seconds)
        {src_tests, false},
        {dev_mode, true},
        %% TODO: extra copies waste space, but mongooseim script requires the files in a certain place
        {include_erts, true},

        {generate_start_script, false},
        {extended_start_script, false},

        %% Don't forget to update tools/test_runner/apply_templates.erl, when changing templates
        {overlay, [
                   {mkdir, "priv/ssl"},
                   {copy, "tools/ssl/mongooseim/cert.pem",        "priv/ssl/fake_cert.pem"},
                   {copy, "tools/ssl/mongooseim/key.pem",         "priv/ssl/fake_key.pem"},
                   {copy, "tools/ssl/mongooseim/server.pem",      "priv/ssl/fake_server.pem"},
                   {copy, "tools/ssl/mongooseim/dh_server.pem",   "priv/ssl/fake_dh_server.pem"},
                   {copy, "tools/ssl/ca/cacert.pem",              "priv/ssl/cacert.pem"},

                   %% Copy the whole directory scripts into scripts.
                   %% Still works, if the destination "scripts/" directory exists.
                   {copy, "rel/files/scripts",   "./"},
                   {copy, "rel/files/templates", "./"},
                   {copy, "rel/files/templates.ini", "etc/templates.ini"},

                   {template, "rel/files/nodetool",     "erts-\{\{erts_vsn\}\}/bin/nodetool"},

                   {template, "rel/files/mongooseim",       "bin/mongooseim"},
                   {template, "rel/files/mongooseimctl",    "bin/mongooseimctl"},
                   {template, "rel/files/app.config",       "etc/app.config"},
                   {template, "rel/files/vm.args",          "etc/vm.args"},
                   {template, "rel/files/vm.dist.args",     "etc/vm.dist.args"},

                   {copy, "priv/logo.txt", "priv/logo.txt"},
                   {copy, "VERSION", "priv/VERSION"}
                  ]}

       ]}.

{dist_node,
 [{setcookie, mongooseim},
  {sname, 'mongooseim@localhost'}
 ]}.

{profiles, [ {prod,    [{relx, [ {dev_mode, false},
                                 {overlay_vars, "rel/prod.vars-toml.config"},
                                 {overlay, [{template, "rel/files/mongooseim.toml", "etc/mongooseim.toml"}]}]},
                                 {erl_opts, [{d, 'PROD_NODE'}]} ]},
             %% development nodes
             {mim1,    [{relx, [ {overlay_vars, "rel/mim1.vars-toml.config"},
                                 {overlay, [
                                     {copy, "rel/files/cets_disco.txt", "etc/cets_disco.txt"},
                                     {template, "rel/files/mongooseim.toml", "etc/mongooseim.toml"}]}]},
                        {deps, [{proper, "1.5.0"}, {meck, "1.0.0"}, {wait_helper, "0.2.1"}]}]},
             {mim2,    [{relx, [ {overlay_vars, "rel/mim2.vars-toml.config"},
                                 {overlay, [
                                     {copy, "rel/files/cets_disco.txt", "etc/cets_disco.txt"},
                                     {template, "rel/files/mongooseim.toml", "etc/mongooseim.toml"}]}]},
                        {deps, [{proper, "1.5.0"}, {meck, "1.0.0"}, {wait_helper, "0.2.1"}]}]},
             {mim3,    [{relx, [ {overlay_vars, "rel/mim3.vars-toml.config"},
                                 {overlay, [
                                     {copy, "rel/files/cets_disco.txt", "etc/cets_disco.txt"},
                                     {template, "rel/files/mongooseim.toml", "etc/mongooseim.toml"}]}]},
                        {deps, [{proper, "1.5.0"}, {meck, "1.0.0"}, {wait_helper, "0.2.1"}]}]},
             {fed1,    [{relx, [{overlay_vars, "rel/fed1.vars-toml.config"},
                                {overlay, [{template, "rel/files/mongooseim.toml", "etc/mongooseim.toml"}]}]},
                        {deps, [{proper, "1.5.0"}, {meck, "1.0.0"}, {wait_helper, "0.2.1"}]}]},
             {reg1,    [{relx, [{overlay_vars, "rel/reg1.vars-toml.config"},
                                {overlay, [{template, "rel/files/mongooseim.toml", "etc/mongooseim.toml"}]}]},
                        {deps, [{proper, "1.5.0"}, {meck, "1.0.0"}, {wait_helper, "0.2.1"}]}]},
             {test,    [{extra_src_dirs, [{"test", [{recursive, true}]}]},
                        {ct_opts, [{ct_hooks, [cth_surefire]}]},
                        {deps, [{proper, "1.5.0"}, {meck, "1.0.0"}, {wait_helper, "0.2.1"}]}]}
            ]}.

{plugins,
 [
  {provider_asn1, "0.4.1"},
  {rebar3_codecov, "0.7.0"},
  {rebar3_lint, "~> 4.0"}
 ]}.

{provider_hooks,
 [{pre,  [{compile, {asn, compile}}]},
  {post, [{clean, {asn, clean}}]
  }]}.

{overrides,
  [
   %% See https://github.com/ninenines/cowboy/issues/1670
   {override, cowboy, [{deps, [{cowlib, "~> 2.0"}]}]},
   %% Erlang JWT Library is in elixir and wants elvis for tests
   %% Remove elvis plugin to reduce deps
   {override, jwerl, [{plugins, [rebar3_elixir, rebar3_hex]}]},
   %% Remove forced proper deps
   {override, nklib, [{deps, []}]},
   %% Remove forced proper deps
   {override, pa, [{deps, []}]},
   %% Force update of `backoff`
   {override, cpool, [{deps, [{backoff, "1.1.6"}]}]},
   %% Remove test profile (pulling old proper) from `backoff`
   {override, backoff, [{profiles, [{test, []}]}]},
   {override, worker_pool, [{minimum_otp_vsn, "26"}]}
 ]}.

{dialyzer, [
    {warnings, [unknown]},
    {plt_extra_apps, [jid, cowboy, cowlib, lasse, p1_utils, ranch, gen_fsm_compat, epgsql, cqerl,
                      common_test, tools, amqp_client, jiffy, erl_csv, inets, compiler, jsx,
                      rabbit_common, mysql, eredis, erlcloud, eodbc, telemetry,
                      nksip, nklib, nkservice, nkpacket, prometheus, exometer_core,
                      mnesia, cets, cpool, tirerl, erlang_doctor]}]}.

{cover_print_enabled, true}.
{cover_export_enabled, true}.
{cover_excl_mods, [eldap_filter_yecc]}.
{coveralls_coverdata, "/tmp/*.coverdata"}.
{coveralls_service_name, "github"}.
{coveralls_parallel, true}.

{codecov_opts,
 [
  %% Assuming /tmp/mongoose_combined.coverdata
  {path, ["/tmp", "_build/test/cover"]},
  {exclude_modules, ['XmppAddr', eldap_filter_yecc]}
 ]}.

{edoc_opts, [{preprocess, true}, {dir, "edoc"}]}.
